/*************************************************************************
 *
*    Used with ICCARM and AARM.
 *
 *    (c) Copyright IAR Systems 2007
 *
 *    File name   : LCD_drv.h
 *    Description : Graphical LCD driver include file
 *
 *    History :
 *    1. Date        : 6, March 2008
 *       Author      : Stanimir Bonev
 *       Description : Create
 *
 *
 *    $Revision: 1.1 $
 **************************************************************************/

#include "../lpc_config.h"


#ifndef INCLUDE_LCD_DRIVE_H
#define INCLUDE_LCD_DRIVE_H

#define C_LCD_CLK_PER_LINE     (C_LCD_H_SIZE + C_LCD_H_PULSE + C_LCD_H_FRONT_PORCH + C_LCD_H_BACK_PORCH)
#define C_LCD_LINES_PER_FRAME  (C_LCD_V_SIZE + C_LCD_V_PULSE + C_LCD_V_FRONT_PORCH + C_LCD_V_BACK_PORCH)
#define C_LCD_PIX_CLK          (5529600)

#define C_LCD_PIX_CLK_DIV 		(CPU_CLOCK_HZ / (Int32U) C_LCD_PIX_CLK )

#define C_LCD_PAGE_SIZE      0x0007F800

// pixel clock frequency < 6.4MHz
// ~5.4Mhz = 408 clk per line * (240 line + 3 Vsynch pulse
//           + 5 front porch + 15 back porch)

#define C_LCD_REFRESH_FREQ     50000000
#define C_LCD_H_SIZE           480
#define C_LCD_H_PULSE          41
#define C_LCD_H_FRONT_PORCH    2
#define C_LCD_H_BACK_PORCH     2
#define C_LCD_V_SIZE           272
#define C_LCD_V_PULSE          1
#define C_LCD_V_FRONT_PORCH    1
#define C_LCD_V_BACK_PORCH     1


typedef struct _Bmp_t {
	UNS_32  H_Size;
	UNS_32  V_Size;
	UNS_32  BitsPP;
	UNS_32  BytesPP;
	pUNS_16 pPalette;
	pUNS_16 pPicStream;
	pUNS_8  pPicDesc;
} Bmp_t, *pBmp_t;



#define C_LCD_PWR_ENA_DIS_DLY  10000
#define C_LCD_ENA_DIS_DLY      10000

#define CRSR_PIX_32     0
#define CRSR_PIX_64     1
#define CRSR_ASYNC      0
#define CRSR_FRAME_SYNC 2

void LCD_Change_Page (const UNS_16 *pPain, const UNS_32 pPage);
void LCD_Init(const UNS_32 *pPain, const UNS_32 * pPallete, const UNS_32 pPage);
void LCD_SetPallet(const UNS_32 * pPallete);
void LCD_Ctrl(BOOL_32 bEna);
void LCD_Cursor_Cfg(int Cfg);
void LCD_Cursor_En(int cursor);
void LCD_Cursor_Dis(int cursor);
void LCD_Move_Cursor(int x, int y);
void LCD_Copy_Cursor(const UNS_32 *pCursor, int cursor, int size);


#endif // __LCD_DRV_H
